package nio;

import java.nio.ByteBuffer;

/**
 * @program: comprehensive-service
 *
 * @description:
 *
 * @author: 窦绍飞
 *
 * @create: 2021-11-25 20:21
 **/
public class NioByteBufferPutGet {
	public static void main(String[] args) {
		// 创建一个buffer
		ByteBuffer byteBuffer = ByteBuffer.allocate(64);

		// 类型化方式放入数据
		byteBuffer.putInt(100);
		byteBuffer.putLong(8);
		byteBuffer.putChar('窦');
		byteBuffer.putShort((short) 4);

		// 取出数据

		byteBuffer.flip();

		System.out.println();

		System.out.println(byteBuffer.getInt());
		System.out.println(byteBuffer.getLong());
		System.out.println(byteBuffer.getChar());
		System.out.println(byteBuffer.getShort());
	}
}
